//
//  TitleBarView.m
//  YoursShow
//
//  Created by Roc on 11-4-12.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "TitleBarView.h"
#import "Topic.h"
#import "PhotoTopic.h"

@implementation TitleBarView

@synthesize title = _title;

- (void) addTitleView: (CGRect) frame  {
    CGRect titleRect = CGRectMake(10, 0, frame.size.width-20, frame.size.height);
    UILabel* title = [[UILabel alloc] initWithFrame:titleRect];
   
    //设置字体
    [title setFont:[UIFont systemFontOfSize:18.0]];

    [title setBackgroundColor:[UIColor clearColor]];
    [title setTextColor:[UIColor whiteColor]];
    title.text = _title;
    
    [self addSubview:title];
    
    [title release];
}

- (void) addGoButton:(CGRect)frame {
    CGRect goRect = CGRectMake(frame.size.width-10-36, frame.size.height/2-18, 36, 36);
    UIButton* goButton = [[UIButton alloc] initWithFrame:goRect];
    
    [goButton setImage:[UIImage imageNamed:@"black_go.png"]
              forState:UIControlStateNormal];
    
    [self addSubview:goButton];
    [goButton release];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithPatternImage:
                                    [UIImage imageNamed:@"black_strip.png"]];
        
        [self addTitleView: frame];
        [self addGoButton:frame];
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame title:(NSString *)title 
{
    self.title = title;
    [self initWithFrame:frame];
    
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (void)dealloc
{
    [super dealloc];
}

@end
